import axios from 'axios'
axios.defaults.baseURL = "http://localhost:9999";

// axios.interceptors.request.use(config=>{
//     console.log("请求拦截",config);
//     return config;
// }, err => {
//     return Promise.reject(err);
// })

axios.interceptors.request.use(function(config){
    if (config.url == '/login' || config.url == '/user' && config.method == 'post') {
        return config
    }
    let token = localStorage.getItem('token');
    // config.headers.authorization = "Bearer " + localStorage.getItem('token');
    config.headers.authorization = "Bearer " + token;
    return config
},function(err){
    console.log("错误拦截",err);
    return Promise.reject(err);
})

export default axios;